/**
 * Created by John on 2016/7/13.
 */
var cursor = wordsColl.find();
cursor.limit(10, function (err, items) {
    items.each(function (err, word) {
        if (word) {
            console.log(word);
        }
    });
});

var fields = {stats: false, value: false, comments: false};
cursor = myColl.find({}, fields);

cursor = collection.find();
cursor = cursor.limit(10);
cursor = cursor.skip(10);

var query = {age: {$gt: 65}};
cursor = myCollection.find(query);
curosr.distinct('last', function (err, lastName) {
    console.log(lastName);
});

var key = {first: true};
var cond = {first: 'a', size: 5};
var initial = {count: 0};
var reduce = function (obj, prev) {
    prev.count++;
};
collection.group(key, cond, initial, reduce, function (err, results) {
    // ...
});

for (var i in results) {
    console.log(results[i]);
}

var group = {
    $group: {_id: '$word', average: {$avg: '$size'}}
};
var limit = {$limit: 10};

collection.aggregate([group, limit], function (err, items) {
    // ...
});

for (var i in results) {
    console.log(results[i]);
}